package org.beanutopia.slot;

import org.beanutopia.exception.PropertyDefinitionException;
import org.beanutopia.function.Injection;
import com.google.common.base.Function;
import com.google.common.base.Predicate;

/**
 * @author ymeymann
 * @since Nov 21, 2007 11:26:16 PM
 */
public interface Slot<A,B> {
  
  Function<Class<?>, Class<?>> BOX = new Function<Class<?>, Class<?>>() {
    public Class<?> apply(Class<?> aClass) {
      if (aClass.isPrimitive()) {
        if (aClass == int.class) return Integer.class;
        if (aClass == boolean.class) return Boolean.class;
        if (aClass == long.class) return Long.class;
        if (aClass == char.class) return Character.class;
        if (aClass == byte.class) return Byte.class;
        if (aClass == float.class) return Float.class;
        if (aClass == short.class) return Short.class;
        if (aClass == double.class) return Double.class;
      }
      return aClass;
    }
  };

  Function<A,B> getProjection();
  Injection<A,B> getInjection();
  Slot<A,B> initialize() throws PropertyDefinitionException;
  Predicate<Object> supported();
}
